<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title>无标题文档</title>
	<link href="/static/css/default.css" rel="stylesheet" type="text/css">
	<link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id='link'>
</head>

<body style="overflow:hidden; padding:10px;">
	<form>
		<table class="formtable" style="width:580px;">

			<tbody>

				<tr>
					<td class="tlabel">角色名称</td>
					<td>
						<input type="text" class="forminput inputstyle1" id="jiaosename" value="{$info.jiaosename}">
					</td>
				</tr>

				<tr>
					<td class="tlabel">备注</td>
					<td>
						<input type="text" class="forminput inputstyle1" id="backinfo" value="{$info.backinfo}">
					</td>
				</tr>

				<tr>
					<td class="tlabel">权限</td>
					<td>
						<div  style="overflow:scroll;height: 400px;">
							{volist name="treelist" id="vo"}
							<p style="height: 25px;"><input type="checkbox" class="parentcheck"  data-key="{$vo.id}" name="quanxian" value="{$vo.valuestr}">{$vo.textstr}</p>
							{volist name="vo['children']" id="td"}
							<p style="padding-left:30px;    height: 25px;"><input type="checkbox" class="children{$vo.id}" name="quanxian" value="{$td.valuestr}">{$td.textstr}</p>
							{/volist}
							{/volist}

						</div>
					</td>
				</tr>



				<tr>
					<td class="tlabel">状态</td>
					<td>
						<select type="text" id="state" class="select" required="required">

							{if condition="$info.state eq 1"}
							<option value="1" selected="selected"> 正常 </option>
							<option value="-1"> 禁用 </option>
							{elseif condition="$info.state eq -1"/}
							<option value="1"> 正常 </option>
							<option value="-1" selected="selected"> 禁用 </option>
							{else /}
							<option value="1"> 正常 </option>
							<option value="-1"> 禁用 </option>
							{/if}


						</select>
					</td>
				</tr>



			</tbody>

		</table>

		<div class="formbtn">
			<input type="button" value="保存" class="btnsave">
			<input type="button" value="取消" class="btncancel">
		</div>
		<input type="hidden" id="id" value="{$info.id}" />
	</form>


</body>
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/vue2.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>


	$(function () {
		$(".parentcheck").click(function(){
			var key = $(this).data("key");
			if ($(this).is(':checked')) {
				$(".children"+key).attr("checked", true);
			}else{
				$(".children"+key).attr("checked", false);
			}

		});

		$(".btnsave").click(function () {
			var id = $("#id").val();
			var jiaosename = $("#jiaosename").val();
			var backinfo = $("#backinfo").val();

			var state = $("#state").val();
			var quanxian = "";
			$("input[name=quanxian]").each(function () {

				if ($(this).is(':checked')) {
					quanxian += $(this).val() + ",";
				}
			});

			if(jiaosename==""){
				layer.msg("请输入角色名称");
				return;
			}

			$.post("/Super/Jiaose/Add", {
				"id": id, "jiaosename": jiaosename, "backinfo": backinfo, "quanxian": quanxian,
				"state": state
			}, function (data) {
				if (data.status == 200) {
					var index = parent.layer.getFrameIndex(window.name);
					window.parent.iframe.contentWindow.location.reload(true);
					console.log(window.parent.iframe);
					parent.layer.close(index);
				} else {
					layer.msg(data.message);
				}
			});
		});
		$(".btncancel").click(function () {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});
	});
	var quanxian = "{$info.quanxian}";
	var arrChk = $("input[name='quanxian']");
	$(arrChk).each(function () {

		if (quanxian.indexOf(this.value + ",") != -1) {

			$(this).attr('checked', 'checked');
		}
	});

</script>

</html>